package lc.com.lcpicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import lc.com.lcpicturebackend.api.aliyun.model.CreateOutPaintingTaskResponse;
import lc.com.lcpicturebackend.model.dto.picture.*;
import lc.com.lcpicturebackend.model.entity.Picture;
import lc.com.lcpicturebackend.model.entity.User;
import lc.com.lcpicturebackend.model.vo.PictureVO;

import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 罗超
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2024-12-28 21:39:43
 */
public interface PictureService extends IService<Picture> {
    /**
     * 上传图片
     *
     * @param inputSource          上传文件
     * @param pictureUploadRequest
     * @param user
     * @return
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadRequest pictureUploadRequest,
                            User user);

    /**
     * 构建SQL查询
     *
     * @param pictureQueryRequest 用户查询请求
     * @return 返回QueryWrapper
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);

    /**
     * 获取单个图片封装信息，关联创建用户信息
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 获取图片封装分页信息，关联创建用户信息
     *
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 图片数据校验方法，用于更新(admin)和修改(user)图片时进行判断
     *
     * @param picture 图片信息
     */
    void validPicture(Picture picture);

    /**
     * 图片审核
     *
     * @param pictureReviewRequest 审核请求
     * @param loginUser            当前登录用户
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    /**
     * 补充审查参数
     *
     * @param picture   图片信息
     * @param loginUser 当前登录用户
     */
    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 批量抓取图片
     *
     * @param pictureUploadByBatchRequest 批量抓取请求
     * @param loginUser                   当前登录用户
     * @return 成功上传的图片数量
     */
    Integer uploadPictureByBatch(PictureUploadByBatchRequest pictureUploadByBatchRequest, User loginUser);

    /**
     * 缓存分页查询
     *
     * @param pictureQueryRequest
     * @param request
     * @return
     */
    Page<PictureVO> listPictureVOByPageWithCache(PictureQueryRequest pictureQueryRequest,
                                                 HttpServletRequest request);

    /**
     * 清理图片资源
     *
     * @param oldPicture 旧图片
     */
    void deletePictureFile(Picture oldPicture);

    /**
     * 删除图片
     *
     * @param pictureId 图片id
     * @param loginUser 当前登录用户
     */
    void deletePicture(long pictureId, User loginUser);

    void editPicture(PictureEditRequest pictureEditRequest, User loginUser);

    /**
     * 检查图片权限
     *
     * @param picture
     * @param loginUser
     */
    void checkPictureAuth(Picture picture, User loginUser);

    /**
     * 根据颜色搜索图片
     *
     * @param spaceId   空间id
     * @param picColor  图片颜色
     * @param loginUser 当前登录用户
     * @return
     */
    List<PictureVO> searchPictureByColor(Long spaceId, String picColor, User loginUser);

    /**
     * 批量编辑图片
     *
     * @param pictureEditByBatchRequst 请求类
     * @param loginUser                当前登录用户
     */
    void editPictureByBath(PictureEditByBatchRequst pictureEditByBatchRequst, User loginUser);

    /**
     * 创建AI扩图任务
     *
     * @param createPictureOutPaintingTaskRequest 请求类
     * @param loginUser       当前登录用户
     * @return 任务id
     */
    CreateOutPaintingTaskResponse createOutPaintingTask(CreatePictureOutPaintingTaskRequest createPictureOutPaintingTaskRequest, User loginUser);
}
